package org.sy.lab.Java7并发编程实战.三线程同步辅助类.三等待多个并发事件的完成;

import java.util.concurrent.CountDownLatch;

public class Videoconference implements Runnable {
	private final CountDownLatch controller;
	public Videoconference(int number) {
		controller = new CountDownLatch(number);
	}
	public void arrive(String name) {
		System.out.printf("%s has arrived.", name);
		controller.countDown();
		System.out.printf("VideoConference: Waiting for %d participants.\n", controller.getCount());
	}
	@Override
	public void run() {
		System.out.printf("VideoConference: Initialization: %d participants.\n", controller.getCount());
		try {
			controller.await();
			System.out.printf("VideoConference: All the participants have come\n");
			System.out.printf("VideoCOnference: Let's start...\n");
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}
